package com.lianxi.exacl.world;


import cn.hutool.core.util.IdUtil;

import fr.opensagres.poi.xwpf.converter.core.IImageExtractor;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.IOException;
import java.util.HashMap;
import java.util.Base64;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class MyIImageExtractor implements IImageExtractor {

    private String uuid;

    private HashMap<String, String> map;

    public MyIImageExtractor(String uuid) {
        this.uuid = uuid;
    }

    public MyIImageExtractor(HashMap<String, String> map) {
        this.map = map;
    }

    @Override
    public void extract(String imagePath, byte[] imageData) throws IOException {
//        ByteArrayInputStream is = new ByteArrayInputStream(imageData);
//        Ftp ftp = new Ftp("10.10.10.249", 21, "t1file", "A8aIm1Gs4V0Fqb");
//        String s = IdUtil.simpleUUID();
//        String filename = StringUtil.substringAfterLast(imagePath, "/");
//        ftp.upload(uuid + "/image/word/media", filename, is);
//        ftp.close();
        map.put("/"+imagePath,Base64.getEncoder().encodeToString(imageData));
    }
}
